//
//  ViewController.m
//  30104
//
//  Created by student on 16/3/17.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "ViewController.h"
#import "MyButton.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIButton *btn;
@property(assign,nonatomic) BOOL appear;
@property(strong,nonatomic) UIButton *btn2;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.appear=NO;
    
    }

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)creatbtn2
{
    self.btn2 =[[UIButton alloc]init];
    self.btn2.bounds=CGRectMake(0, 0, 200, 200);
    self.btn2.center=CGPointMake(100, -100);
    [self.btn2 setImage:[UIImage imageNamed:@"对话框"] forState: UIControlStateNormal];
    [self.btn2 setImage:[UIImage imageNamed:@"小孩"] forState: UIControlStateHighlighted];


}
- (IBAction)pressed:(MyButton *)sender
{
    
    if(self.appear)
    {
        [self.btn2 removeFromSuperview];
    }
    else
    {
        [self creatbtn2];
        [sender addSubview:self.btn2];
        sender.addBtn=self.btn2;
    }
    self.appear=!self.appear;
        
    

}

@end
